package main

import (
	"fmt"
	"github.com/go-redis/redis"
	"time"
)

func main() {
	testJson()
	//r := rand.New(rand.NewSource(time.Now().UnixNano()))
	//for {
	//	//time.Sleep(time.Second * 1)
	//	fmt.Println(r.Intn(10))
	//}

}

func IsOpenTime() bool {
	isOpen := false
	nowHour := time.Now().Hour()
	nowMinute := time.Now().Minute()
	if (11 > nowHour && nowHour >= 10) || (nowHour >= 13 && nowHour < 14) || (nowHour >= 18 && nowHour < 19) {
		isOpen = true
	} else if nowHour == 20 {
		if nowMinute >= 30 {
			isOpen = true
		}

	} else if nowHour == 21 {
		if nowMinute < 30 {
			isOpen = true
		}
	}
	return isOpen
}

type Bpoint struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

type InitPropConfig struct {
	LocationId      uint32              `json:"location_id"`
	Location        Bpoint              `json:"location"`
	RefreshPropList []RefreshPropConfig `json:"refresh_prop_list"`
}

type RefreshPropConfig struct {
	GoodsId   uint32 `json:"goods_id"`
	GoodsName string `json:"goods_name"`
	YuanLiNum uint32 `json:"yuan_li_num"`
}

func testJson() {
	//jsonStr := "[{\"location_id\":1,\"location\":{\"x\":10.0,\"y\":20.0,\"z\":30.0},\"refresh_prop_list\":[{\"goods_id\":1022,\"goods_name\":\"枪\",\"yuan_li_num\":0},{\"goods_id\":1023,\"goods_name\":\"载具\",\"yuan_li_num\":0},{\"goods_id\":0,\"goods_name\":\"\",\"yuan_li_num\":20}]}]"
	rdb := redis.NewClient(&redis.Options{
		Addr:     "r-bp1v3q1zerm2y5mz6npd.redis.rds.aliyuncs.com:6379",
		Password: "peng_pre_redis663SC3H1K32g3b", // no password set
		DB:       6,                              // use default DB
	})
	redisKey1 := "lejianprop_refresh_init_config"
	result, err := rdb.HGet(redisKey1, fmt.Sprintf("%d:%d", 92, 1)).Result()
	//var m []InitPropConfig
	fmt.Println("result", result)
	//err = json.Unmarshal([]byte(result), &m)
	//if err != nil {
	//	fmt.Println(err)
	//}
	result1, _ := rdb.HGet(fmt.Sprintf("dayou_space:house_set:%d_%d", 1, 87), fmt.Sprint(1)).Result()
	fmt.Println("result1", result1)
	//fmt.Println(m[0].Location.Z)
	_, err = rdb.Del("dsaweaweawe").Result()
	fmt.Println("err:", err)
	//for _, data := range m {
	//	fmt.Println("data.LocationId", data.LocationId)
	//	fmt.Println("data.Location", data.Location)
	//	for _, prop := range data.RefreshPropList {
	//		fmt.Println(prop.GoodsId)
	//		fmt.Println(prop.GoodsName)
	//		fmt.Println(prop.YuanLiNum)
	//	}
	//}
}
